<?php

class GoodsTypeIdValidator extends CValidator{

	protected function validateAttribute($object, $attribute) {
		$model = GoodsType::model()->findByPk($object->{$attribute});
		if (is_object($model)) {
			$children = $model->getDescendants();
			if (!empty($children)) {
				$object->addError($attribute, '请选择末级分类!');
			}
		} else
			$object->addError($attribute, '分类选择有误!');
	}
}

?>